package org.example.ai_chat.util;

/**
 * 自定义异常类
 */
public class CustomException extends RuntimeException{
    // 错误状态码
    private Integer code;

    /**
     * 根据状态码和错误信息来创建对象
     * @param code 错误状态码
     * @param msg 错误信息
     */
    public CustomException(Integer code, String msg) {
        super(msg);
        this.code = code;
    }


    /**
     * 根据自定义相应信息来创建对象
     * @param resultCodeEnum 自定义响应状态枚举类
     */
    public CustomException(ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.getMsg());
        this.code = resultCodeEnum.getCode();
    }

    public Integer getCode() {
        return code;
    }
}
